package com.strategy.demo02;

/**
 * 策略模式案例
 * 上下文类Context负责把策略封装起来，具体怎么自由地切换策略则是由高层模块Client负责声明的
 */
public class Client {
    public static void main(String[] args) {
        Add add = new Add();
        Context context = new Context(add);
        int result1 = context.exec(1, 1);
        System.out.println("1+1="+result1);

        Sub sub = new Sub();
        context = new Context(sub);
        int result2 = context.exec(1, 1);
        System.out.println("1-1="+result2);
    }
}
